package com.dianxin.smartpark.web.weChat;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.smartpark.dao.dataobject.weChat.MobileRequest;
import com.dianxin.smartpark.service.weChat.WeChatService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @program: smart-park
 * @description: 微信小程序
 * @author: chenyong
 * @create: 2021-08-26 20:06
 */
@RestController
@RequestMapping("/smartpark/weChat/")
public class WeChatController {
    @Resource
    private WeChatService weChatService;

    /**
     * 通过code获取open_id
     * @Description:  通过code获取open_id
     * @Author: ChenYong
     * @Date: 2021/8/27 0027
     * @param code:
     * @Return: CommonResponseBody
     */
    @PostMapping(value = "/sign")
    public CommonResponseBody sign(String code) {
        return weChatService.sign(code);
    }

    /**
     * 通过code获取手机号
     * @Description:  通过code获取手机号
     * @Author: ChenYong
     * @Date: 2021/8/27 0027
     * @param mobileRequest:
     * @Return: CommonResponseBody
     */
    @PostMapping(value = "/getPhoneNumber")
    public CommonResponseBody getPhoneNumber(@RequestBody MobileRequest mobileRequest) throws Exception {
        return weChatService.getPhoneNumber(mobileRequest);
    }

    /**
     * 获取小程序二维码
     * @Description:  获取小程序二维码
     * @Author: ChenYong
     * @Date: 2021/8/27 0027
     * @param mobileRequest:
     * @Return: CommonResponseBody
     */
    @PostMapping(value = "/getWeChatCode")
    public CommonResponseBody getWeChatCode(@RequestBody MobileRequest mobileRequest){
        return weChatService.getWeChatCode(mobileRequest);
    }
}
